package cn.com.nes.site.entity.em.project;

import cn.com.nes.common.exception.NoSuchEnumException;

import java.util.HashMap;
import java.util.Map;

/**
 * 项目类型 枚举
 *  值域对应 t_param 表 param_type=92
 */
public enum ProjectTypeEnum {
    /**
     * 民用
     */
    CIVIL("01", "C_"),
    /**
     * 企业
     */
    BUSINESS("02", "B_"),
    /**
     * 政府
     */
    GOVERNMENT("03", "G_"),
    ;

    private String key;

    private String value;

    ProjectTypeEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static String getKey(String key) {
        Map<String, String> map = new HashMap<>();
        for (ProjectTypeEnum projectTypeEnum : values()) {
            map.put(projectTypeEnum.getKey(), projectTypeEnum.getValue());
        }
        if (!map.containsKey(key)) {
            throw new NoSuchEnumException("未匹配的项目类型");
        }
        return map.get(String.valueOf(key));
    }

}
